using namespace std;
#include<iostream>

class Solution {
public:
    string removeDuplicates(string s) {
        string ret;
        for (int i = 0; i < s.size(); i++)
        {
            if (ret.size() && ret.back() == s[i])
                ret.pop_back();
            else
                ret += s[i];
        }

        return ret;

    }
};



class Solution {
public:
    bool backspaceCompare(string s, string t) {
        return Change(s) == Change(t);
    }

    string Change(string& s)
    {
        string ret;
        for (auto ch : s)
        {
            if (ret.size() && ch == '#')
                ret.pop_back();
            else
            {
                if (ch != '#')
                    ret += ch;
            }
        }

        cout << ret << endl;

        return ret;
    }
};